home *** CD-ROM | disk | FTP | other *** search
/ Linux Cubed Series 7: Sunsite / Linux Cubed Series 7 - Sunsite Vol 1.iso / system / news / inn1.000 / inn1.4sec-linux-src.tar / inn / lib / cleanfrom.c < prev    next >
C/C++ Source or Header  |  1992-07-24  |  981b  |  49 lines

  1. /*  $Revision: 1.4 $
  2. **
  3. */
  4. #include <stdio.h>
  5. #include <sys/types.h>
  6. #include "configdata.h"
  7. #include "clibrary.h"
  8. #include "macros.h"
  9.  
  10. #define LPAREN    '('
  11. #define RPAREN    ')'
  12.  
  13.  
  14. /*
  15. **  Clean up a from line, making the following transformations:
  16. **    address            address
  17. **    address (stuff)        address
  18. **    stuff <address>        address
  19. */
  20. void
  21. HeaderCleanFrom(from)
  22.     char        *from;
  23. {
  24.     register char    *p;
  25.     register char    *end;
  26.  
  27.     /* Do the equivalent of sed's "1q" */
  28.     if ((p = strchr(from, '\n')) != NULL)
  29.     *p = '\0';
  30.  
  31.     /* Do pretty much the equivalent of sed's "s/ (.*)//"; doesn't
  32.      * work for "(save (delete this)" but that's okay. */
  33.     if ((p = strchr(from, LPAREN))
  34.      && p > from
  35.      && *--p == ' '
  36.      && (end = strrchr(p, RPAREN))) {
  37.     while (*++end)
  38.         *p++ = *end;
  39.     *p = '\0';
  40.     }
  41.  
  42.     /* Do the equivalent of sed's "s/.*<\(.*\)>/\1/" */
  43.     if ((p = strrchr(from, '<')) && (end = strrchr(p, '>'))) {
  44.     while (++p < end)
  45.         *from++ = *p;
  46.     *from = '\0';
  47.     }
  48. }
  49.